import * as proxy from '../proxy';
import ServiceBase from '../base';
import {SubscriptionPageProxy, SubscriptionProxy} from '../proxies/file-proxy';
const GET_FILES = '/accounts';

class SubscriptionsService extends ServiceBase {
    // POST /accounts/{accountId}/projects/{projectId}/subscriptions 订阅
    postSubscription = (data) => {
        let promise = super.post({
            url: `${GET_FILES}/${data.accountId}/projects/${data.projectId}/subscriptions`,
            data: data.data,
        });
        return proxy.httpResultProxy(promise, SubscriptionProxy);
    };
    // GET /accounts/{accountId}/projects/{projectId}/subscriptions get订阅信息
    getSubscriptions = (data?) => {
        let promise = super.get({
            url: `${GET_FILES}/${data.accountId}/projects/${data.projectId}/subscriptions`,
        });
        return proxy.httpResultProxy(promise, SubscriptionPageProxy);
    };
    // GET /accounts/{accountId}/projects/{projectId}/subscriptions/search  查询订阅信息
    getSubscriptionsSearch = (data) => {
        let promise = super.get({
            url: `${GET_FILES}/${data.accountId}/projects/${data.projectId}/subscriptions/search`,
            params: data.query,
        });
        return proxy.httpResultProxy(promise, SubscriptionPageProxy);
    };
    // DELETE /accounts/{accountId}/projects/{projectId}/subscriptions delete
    deleteSubscriptions = (data) => {
        let promise = super.delete({
            url: `${GET_FILES}/${data.accountId}/projects/${data.projectId}/subscriptions`,
            data: data.data,
        });
        return proxy.httpResultProxy(promise);
    };
}

export {SubscriptionsService};
